//
//  HomeLookRangeBottomView.m
//  FD
//
//  Created by xiaofang wang on 2019/1/14.
//  Copyright © 2019年 ZhiYuan Network. All rights reserved.
//
// 44*2

#import "HomeLookRangeBottomView.h"
@interface HomeLookRangeBottomView()
/**是否在配送范围label*/
@property (nonatomic, strong) UILabel *deliveryRangeLabel;
/**立即点餐按钮*/
@property (nonatomic, strong) UIButton *instantOrderButton;
/**viewArr*/
@property (nonatomic, strong) NSMutableArray *viewArrM;
@end

@implementation HomeLookRangeBottomView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    [self addSubview:self.deliveryRangeLabel];
    [self addSubview:self.instantOrderButton];
    
    [self.viewArrM addObject:self.deliveryRangeLabel];
    [self.viewArrM addObject:self.instantOrderButton];
}

#pragma mark - layout
- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.viewArrM mas_distributeViewsAlongAxis:(MASAxisTypeVertical) withFixedSpacing:0 leadSpacing:0 tailSpacing:0];
    [self.viewArrM mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
    }];
}

#pragma mark - getter
- (NSMutableArray *)viewArrM {
    if (!_viewArrM) {
        _viewArrM = [NSMutableArray array];
    }
    return _viewArrM;
}

- (UILabel *)deliveryRangeLabel {
    if (!_deliveryRangeLabel) {
        _deliveryRangeLabel = [UILabel new];
        _deliveryRangeLabel.backgroundColor = [UIColor whiteColor];
        _deliveryRangeLabel.textAlignment = NSTextAlignmentCenter;
        
        _deliveryRangeLabel.text = NSLocalizedString(L_Home_BZSHQY, @"这不在我们的送货区域(支持自提)");
        _deliveryRangeLabel.numberOfLines = 0;
    }
    return _deliveryRangeLabel;
}
- (UIButton *)instantOrderButton {
    if (!_instantOrderButton) {
        _instantOrderButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        _instantOrderButton.backgroundColor = kMainRedColor;
        
        NSString *ljdcStr = NSLocalizedString(L_Home_OrderNow, @"立即点餐");
        [_instantOrderButton setTitle:ljdcStr forState:(UIControlStateNormal)];
        
        [_instantOrderButton setTitleColor:[UIColor whiteColor] forState:(UIControlStateNormal)];
        [_instantOrderButton addTarget:self action:@selector(clickInstantOrderAction:) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _instantOrderButton;
}

#pragma mark - 点击事件
- (void)clickInstantOrderAction:(UIButton *)btn {
    
    if (self.clickInstantOrderBlock) {
        self.clickInstantOrderBlock();
    }
}

/**更新文字显示内容*/
- (void)updateDeliveryRangeLabelTitle:(NSString *)title {
    self.deliveryRangeLabel.text = title;
}

@end
